package guda.house.dal.dao.impl;

import guda.grape.autogen.common.BaseDAO;
import guda.house.dal.dao.AccountEstateDAO;
import guda.house.dal.dataobject.AccountEstateDO;
import guda.grape.autogen.common.page.BaseQuery;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class AccountEstateDAOImpl extends BaseDAO implements AccountEstateDAO {

    @Override
	public Long insert(AccountEstateDO accountEstate) {
	      try {
                return (Long) getSqlMapperW().insert("account_estate.insert",accountEstate);
          } catch (Exception e) {
                throw new RuntimeException(e);
          }

	}

    @Override
	public AccountEstateDO getAccountEstateById(Long accountId) {
	    return (AccountEstateDO)getSqlMapClientTemplate().queryForObject("account_estate.getAccountEstateById", accountId);
	}

    @Override
	public boolean delAccountEstateById(Long accountId) {
	    int num = 0;
        try {
            num = getSqlMapperW().delete("account_estate.delAccountEstateById",accountId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        if(num>0){
            return true;
        }else{
            return false;
        }
	}

    @Override
	public List<AccountEstateDO> getAccountEstateByIds(List idsList) {
        Map m = new HashMap();
        m.put("idsList",idsList);
		return getSqlMapClientTemplate().queryForList("account_estate.selectByIds", m);
	}

    @Override
	public void cleanAutoIncrement(Long accountId) {
	    try {
            getSqlMapperW().update("account_estate.cleanAutoIncrement",accountId);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
	}

    @Override
    public List<AccountEstateDO> selectForPage(BaseQuery baseQuery) {
        return getSqlMapClientTemplate().queryForList("account_estate.selectForPage", baseQuery);
    }

    @Override
    public int countForPage(BaseQuery baseQuery) {
        return (Integer)getSqlMapClientTemplate().queryForObject("account_estate.countForPage",baseQuery);
    }

    @Override
    public void updateByIdSelective(AccountEstateDO accountEstate) {
        try {
            getSqlMapperW().update("account_estate.updateByIdSelective",accountEstate);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    @Override
    public Long stat(List<Long> suitIdList, String gmtDate, String accountType) {
        Map m = new HashMap();
        m.put("suitIdList",suitIdList);
        m.put("gmtDate",gmtDate);
        m.put("accountType",accountType);
        return (Long)getSqlMapClientTemplate().queryForObject("account_estate.stat", m);
    }

}

